package com.reverie.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author Rui.Zhou
 * @since 2024-02-03
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("mh_order_info")
public class OrderInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "order_id", type = IdType.AUTO)
    private Integer orderId;

    private String orderSn;

    private Integer userId;

    private Integer orderStatus;

    /**
     * 1:准
     */
    private Integer shippingStatus;

    /**
     * 1:未
     */
    private Integer payStatus;

    private String consignee;

    private Integer country;

    private Integer province;

    private Integer city;

    private Integer district;

    private String provinceName;
    private String cityName;
    private String districtName;

    private String address;

    private String zipcode;

    private String tel;

    private String mobile;

    private String email;

    private String bestTime;

    private String signBuilding;

    private String postscript;

    private String shippingId;

    private String shippingName;

    private Integer payId;

    private String payName;

    private String howOos;

    private String howSurplus;

    private String packName;

    private String cardName;

    private String cardMessage;

    private String invPayee;

    private String invContent;

    private BigDecimal goodsAmount;

    private BigDecimal shippingFee;

    private BigDecimal insureFee;

    private BigDecimal payFee;

    private BigDecimal packFee;

    private BigDecimal cardFee;

    private BigDecimal moneyPaid;

    private BigDecimal surplus;

    private Integer integral;

    private BigDecimal integralMoney;

    private BigDecimal bonus;

    private BigDecimal orderAmount;

    private Integer fromAd;

    private String referer;

    private long addTime;
    private Integer confirmTime;
    private Integer payTime;

    private Boolean packId;

    private String cardId;

    private Integer bonusId;

    private String invoiceNo;

    private String extensionCode;

    private Integer extensionId;

    private String toBuyer;

    private String payNote;

    private Integer agencyId = 0;

    private String invType = "";

    private BigDecimal tax = new BigDecimal("0");

    @TableField("is_separate")
    private Boolean separate;

    private Integer parentId;

    private BigDecimal discount;

    private Integer modifyAt;

    private Integer shippingAt;

    private String couponId;

    @TableField("is_anoy")
    private Boolean anoy;

    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate shippingDay;

    private Integer shippingHour;

    /**
     * 贺卡 0未审核 1已审核
     */
    private String isCheckCard;

    private String sapSync;

    /**
     * U
     */
    private String sapTag;

    private String shipperName;

    private String shipperSn;

    /**
     * 1,2,3
     */
    private String refererSn;

    private String storeSn;

    private String exCode;

    /**
     * 订单完成时间
     */
    private Integer finishedTime;

    private String location;

    @TableField(exist = false)
    private String userName;
    @TableField(exist = false)
    private String addTimeText;
    @TableField(exist = false)
    private String shippingText;
    @TableField(exist = false)
    private String submitUserPhone;
    @TableField(exist = false)
    private List<OrderGoods> goodList;
    @TableField(exist = false)
    private Boolean isFirst;
    @TableField(exist = false)
    private Integer buyOrderNumber;

    @TableField(exist = false)
    private String couponName;

    @TableField(exist = false)
    private String orderStatusStr;
    public String getOrderStatusStr() {
        if(orderStatus==null){
            return "";
        }
        switch (orderStatus){
            case 1:
                orderStatusStr = "已下单";
                break;
            case 2:
                if(this.payId == 103 || this.payId == 105){
                    orderStatusStr = "已支付";
                }else if(this.payId == 104){
                    orderStatusStr = "已下单";
                }
                break;
            case 3:
                orderStatusStr = "已出库";
                break;
            case 4:
                orderStatusStr = "配送中";
                break;
            case 5:
                orderStatusStr = "已完成";
                break;
            case 6:
                orderStatusStr = "退款中";
                break;
            case 7:
                orderStatusStr = "已退款";
                break;
            case 8:
                orderStatusStr = "已取消(后台取消)";
                if(this.payStatus == 3){
                    orderStatusStr = "已取消(自动退款)";
                }
                break;
            default:
        }
        return orderStatusStr;
    }
}
